import Vue from "vue";
import Vuex from "vuex";

const files = require.context('./modules', false, /\.js$/);
const modules = {}
files.keys().forEach((key) => {
    if (!/.?\/?([a-zA-Z]+).js$/.test(key)) return;
    if (key === './index.js' || !files(key).default) return;
    const name = key.replace(/^.?\/?([a-zA-Z]+).js$/ig, "$1")
    if (!/^[a-z]+$/i.test(name)) return;
    const k = name.slice(0, 1).toUpperCase() + name.slice(1);
    modules[k] = files(key).default;
});


Vue.use(Vuex);

export default new Vuex.Store({
    modules: modules,
});
